package org.jeecg.modules.depart.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 * 部门表
 * <p>
 *
 * @Author Steve
 * @Since 2019-01-22
 */
@Data
@TableName("sys_depart")
public class SysDepart implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    /**
     * 父机构ID
     */
    private String parentId;
    /**
     * 机构/部门名称
     */
    @Excel(name = "机构/部门名称", width = 15)
    private String departName;
    /**
     * 英文名
     */
    @Excel(name = "英文名", width = 15)
    private String departNameEn;
    /**
     * 缩写
     */
    private String departNameAbbr;
    /**
     * 排序
     */
    @Excel(name = "排序", width = 15)
    private Integer departOrder;
    /**
     * 描述
     */
    @Excel(name = "描述", width = 15)
    private String description;
    /**
     * 机构类别 1=公司，2=组织机构，3=岗位
     */
    @Excel(name = "机构类别", width = 15, dicCode = "org_category")
    private String orgCategory;
    /**
     * 机构类型
     */
    private String orgType;
    /**
     * 机构编码
     */
    @Excel(name = "机构编码", width = 15)
    private String orgCode;
    /**
     * 手机号
     */
    @Excel(name = "手机号", width = 15)
    private String mobile;
    /**
     * 传真
     */
    @Excel(name = "传真", width = 15)
    private String fax;
    /**
     * 地址
     */
    @Excel(name = "地址", width = 15)
    private String address;
    /**
     * 备注
     */
    @Excel(name = "备注", width = 15)
    private String memo;
    /**
     * 状态（1启用，0不启用）
     */
    @Dict(dicCode = "depart_status")
    private String status;
    /**
     * 删除状态（0，正常，1已删除）
     */
    @Dict(dicCode = "del_flag")
    private String delFlag;
    /**
     * 对接企业微信的ID
     */
    private String qywxIdentifier;
    /**
     * 创建人
     */
    private String createBy;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 更新人
     */
    private String updateBy;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("组织ID")
    @Dict(dictTable = "cy_platform_organization_info", dicText = "name", dicCode = "id")
    private String organizationId;

    /**
     * 是否核算主体
     */
    @Excel(name = "是否核算主体", width = 15)
    @ApiModelProperty(value = "核算主体")
    private boolean costCalcSubject;

    //update-begin---author:wangshuai ---date:20200308  for：[JTC-119]在部门管理菜单下设置部门负责人，新增字段负责人ids和旧的负责人ids
    /**
     * 部门负责人的ids
     */
    @TableField(exist = false)
    private String directorUserIds;
    /**
     * 旧的部门负责人的ids(用于比较删除和新增)
     */
    @TableField(exist = false)
    private String oldDirectorUserIds;


    @ApiModelProperty(value = "统一社会信用代码")
    private String unifiedSocialCreditIdentifier;

    @ApiModelProperty(value = "联系人")
    private String contactUser;
    @ApiModelProperty(value = "联系电话")
    private String contactNumber;
    @ApiModelProperty(value = "联系电话前缀")
    private String contactNumberPrefix;

    @ApiModelProperty(value = "联系邮箱")
    private String contactMail;

    @ApiModelProperty(value = "认证人")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id")
    private String approveUser;

    @ApiModelProperty(value = "认证时间")
    private Date approveDate;

    @ApiModelProperty(value = "法定代表人")
    private String legalRepresentative;

    @ApiModelProperty(value = "成立时间")
    private String establishedTime;

    @ApiModelProperty(value = "行业")
    private String industry;

    @ApiModelProperty(value = "国家/地区")
    private String region;

    @ApiModelProperty(value = "是否是顶级组织")
    private Boolean topOrg;

    @ApiModelProperty(value = "上级组织持有比例")
    private String superiorShareholdingRatio;

    @ApiModelProperty(value = "自定义组织类型")
    @Dict(dicCode = "org_model_code")
    private String orgModelCode;

    @ApiModelProperty(value = "是否管理员")
    @TableField(exist = false)
    private Boolean adminFlag;

    @ApiModelProperty(value = "公司简介")
    private String orgContent;

    //update-end---author:wangshuai ---date:20200308  for：[JTC-119]新增字段负责人ids和旧的负责人ids

    /**
     * 重写equals方法
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SysDepart depart = (SysDepart) o;
        return Objects.equals(id, depart.id) &&
                Objects.equals(parentId, depart.parentId) &&
                Objects.equals(departName, depart.departName) &&
                Objects.equals(departNameEn, depart.departNameEn) &&
                Objects.equals(departNameAbbr, depart.departNameAbbr) &&
                Objects.equals(departOrder, depart.departOrder) &&
                Objects.equals(description, depart.description) &&
                Objects.equals(orgCategory, depart.orgCategory) &&
                Objects.equals(orgType, depart.orgType) &&
                Objects.equals(orgCode, depart.orgCode) &&
                Objects.equals(mobile, depart.mobile) &&
                Objects.equals(fax, depart.fax) &&
                Objects.equals(address, depart.address) &&
                Objects.equals(memo, depart.memo) &&
                Objects.equals(status, depart.status) &&
                Objects.equals(delFlag, depart.delFlag) &&
                Objects.equals(createBy, depart.createBy) &&
                Objects.equals(createTime, depart.createTime) &&
                Objects.equals(updateBy, depart.updateBy) &&
                Objects.equals(updateTime, depart.updateTime);
    }

    /**
     * 重写hashCode方法
     */
    @Override
    public int hashCode() {

        return Objects.hash(super.hashCode(), id, parentId, departName,
                departNameEn, departNameAbbr, departOrder, description, orgCategory,
                orgType, orgCode, mobile, fax, address, memo, status,
                delFlag, createBy, createTime, updateBy, updateTime);
    }
}
